<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>学生登陆</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="js/jquery-3.3.1.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="js/bootstrap.min.js"></script>
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <script src="js/vue.js"></script>
    <script src="js/axios.min.js"></script>
    <style>
        .center{
            left: 38%;
        }
        #eyes{
            position: absolute;
            right: -15px;
            top: 35%;
        }
    </style>
</head>
<body>
<div id="all" style="text-align: center">
    <h1>图书馆座位预约系统-学生登陆</h1>
    <div class="input-group center btn-lg" style="width: 350px">
        <span class="input-group-addon" id="studentNum">学&nbsp&nbsp&nbsp号</span>
        <input type="text" v-model:value="studentNum" class="form-control" placeholder="" aria-describedby="basic-addon1">
    </div>

    <div class="input-group center btn-lg" style="width: 350px">
        <span class="input-group-addon" id="password">密&nbsp&nbsp&nbsp码</span>
        <input v-bind:type="passwordDisplay" v-model:value="password" class="form-control" placeholder="" aria-describedby="basic-addon1">
        <span id="eyes" @click="looking" v-bind:class="eyesClass" aria-hidden="true"></span>
    </div>
    <div class="btn-group btn-lg" style="left: -10%" role="group" aria-label="...">
        <button type="button" @click="checkUser" class="btn btn-default">提交</button>
    </div>
</div>
</body>
<script>
    var v1=new Vue({
        el:"#all",
        data:{
            studentNum:"",
            password:"",
            passwordDisplay:"password",
            eyesClass:"glyphicon glyphicon-eye-open"
        },
        methods:{
            looking(){
                //定义一个方法，用于修改密码框的显示效果
                if (this.passwordDisplay=="text"){
                    //当前密码框可见密码，用户点击以后，将眼睛修改为闭眼glyphicon glyphicon-eye-close,并且将密码框样式改为password
                    this.passwordDisplay="password";
                    this.eyesClass="glyphicon glyphicon-eye-open"
                }else{
                    this.passwordDisplay="text";
                    this.eyesClass="glyphicon glyphicon-eye-close"
                }
            },
            checkUser(){
                // //发送ajax请求
                $.ajax({
                    type:"post",
                    url:"studentLogin",
                    data:{
                        "studentNum":this.studentNum,
                        "password":this.password,
                    },
                    async:false,
                    success:function (resp) {
                        eval(resp);
                        if (resp.loginResult=="true"){
                            location.href="studentStatus.html";
                        }else{
                            alert(resp.errorReason);
                        }
                    }
                })
            }
        }
    })
</script>
</html>